<template>
  <view class="pageLayout">
    <view
      class="cus_car"
      v-for="item in dataList"
      :key="item.customerID"
      @click="clickItem(item)"
    >
      <view class="cus_box"> 场次名称：{{ item.classeseName }} </view>
      <view class="time">
        <view class="time_detail">场次日期：{{ item.date }}</view>
      </view>
      <view class="time">
        <view class="time_detail">预约时间：{{ item.venueTime }}</view>
      </view>
      <view class="time">
        <view class="time_detail"
          >场次时间：{{ formatTimestamp(item.startTime, "onlyDate") }}/
          {{ formatTimestamp(item.startTime, "getHouseMin") }}—{{
            formatTimestamp(item.endTime, "getHouseMin")
          }}</view
        >
      </view>
    </view>
    <view v-if="dataList.length == 0">
      <u-empty mode="list"> </u-empty>
    </view>
  </view>
</template>
  
  <script>
import store from "../../store/index";
import { queryCurrentClasseseRecordPageList } from "../api/classeseRecord/index.js";
export default {
  components: {},
  data() {
    return {
      dataList: [],
      listForm: {
        pageIndex: 1,
        pageSize: 10,
      },
      isMore: false,
      loading: false,
      totalPages: 0, //总页数
    };
  },
  computed: {
    hasLogin() {
      return this.$store.state.token && this.$store.state.token.length > 0;
    },
  },
  onLoad(options) {
    this.resetSearch();
  },
  methods: {
    /**
     * 点击列表跳转详情页
     */
    clickItem(item) {},
    /**
     * 获取列表
     */
    getList() {
      this.isMore = true;
      this.loading = true;
      queryCurrentClasseseRecordPageList(this.listForm)
        .then((res) => {
          this.dataList = [...this.dataList, ...res.data.items];
          this.totalPages = res.data.totalPages;
          this.isMore = false;
          this.loading = false;
        })
        .catch((e) => {
          this.isMore = false;
          this.loading = false;
          let message;
          if (e.data && e.data.detail) {
            message = e.data.detail;
          } else {
            message = e.errorMsg;
          }
          uni.showToast({
            title: message,
            icon: "none",
            duration: 2000,
          });
        });
    },
    /**
     * 重置分页
     */
    resetSearch() {
      this.listForm.pageIndex = 1;
      this.listData = [];
      this.getList();
    },
  },
  onShow() {},
  /**
   * 上拉加载更多
   */
  onReachBottom() {
    if (this.isMore) {
      return;
    }
    if (this.listForm.pageIndex < this.totalPages) {
      this.listForm.pageIndex++;
      this.getList();
    }
  },
};
</script>
  <style>
page {
  background-color: #f5f7fb;
}
</style>
  <style lang="scss" scoped>
.pageLayout {
  padding: 40rpx;
}
.cus_car {
  background-color: #ffffff;
  width: 670rpx;
  padding: 40rpx;
  box-sizing: border-box;
  margin-bottom: 24rpx;
  .top {
    display: flex;
    color: #1c1b2680;
    font-size: 20rpx;
    justify-content: flex-end;
  }
  .cus_box {
    font-weight: 700;
    color: #000000;
    font-size: 24rpx;
  }
  .tips_box {
    display: flex;
    .tips {
      padding: 2rpx 18rpx;
      font-size: 16rpx;
      margin-right: 5rpx;
      margin-top: 8rpx;
    }
    .s {
      color: #a22c26;
      border: 1rpx solid #a22c26;
      background-color: #fbe6e8;
    }
    .a {
      color: #fe8b00;
      border: 1rpx solid #fe8b00;
      background-color: #fff9eb;
    }
    .b {
      color: #52c41a;
      border: 1rpx solid #52c41a;
      background-color: #f6ffed;
    }
    .c {
      color: #1677ff;
      border: 1rpx solid #1677ff;
      background-color: #e6f4ff;
    }
    .d {
      color: #b088fa;
      border: 1rpx solid #b088fa;
      background-color: #f0e8ff;
    }
  }
  .time {
    display: flex;
    align-items: baseline;
    font-size: 22rpx;
    margin-top: 12rpx;
    .time_detail {
    }
  }
  .server_box {
    display: flex;
    align-items: baseline;
    font-size: 22rpx;
    margin-top: 12rpx;
    .u-icon {
      margin-right: 10rpx;
    }
    .server_name {
      margin-left: 10rpx;
      margin-right: 10rpx;
    }
    .server_gropup {
      margin-left: 10rpx;
    }
  }
}
.row2 {
  display: flex;
  justify-content: space-between;
}
</style>